#include <stdio.h>

int main(int argc, char const *argv[])
{
    if( argc != 2 )
    {
        printf( "Pls input: ./a.out <src fie name\n>" );
        return -1;
    }

    FILE * fpSrc = fopen( argv[1], "r" );
    if( NULL == fpSrc )
    {
        perror( "Fail to open file" );
        return -1;
    }

    int iCounter=0;
    int iRet;

    while( ( iRet = fgetc( fpSrc ) ) != EOF )
    {
        if( iRet == '\n')
        {
            ++iCounter;
        }
    }

    fclose( fpSrc );

    printf( "Totle line# of file <%s> is %d\n", argv[1], iCounter );
    
    return 0;
}


/**************************************************************
作业要求：
从终端输入一个文件名,统计该文件有多少行

**************************************************************/